using MicroMsg.Common.Event;
using MicroMsg.Manager;
using MicroMsg.Resource.@string;
using MicroMsg.Scene;
using MicroMsg.Storage;
using MicroMsg.UI.UserContrl;
using MicroMsg.UI.Util;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
namespace MicroMsg.UI.Page
{
	public class QQDetailInfoWeixinOff : BasePage
	{
		private EventWatcher m_WatcherInviteErr;
		private EventWatcher m_WatcherInviteSuc;
		private QFriend mCuFriend;
		internal Grid LayoutRoot;
		internal panelTitle2Line panelTitle;
		internal StackPanel ContentPanel;
		internal Grid QQArea;
		internal Image QQImg;
		internal TextBlock QQNumTxt;
		internal EmojiText QQNickNameTxt;
		internal TextBlock QQInfoTxt;
		internal Button OkBtn;
		internal Button SendQQMsg;
		private bool _contentLoaded;
		public QQDetailInfoWeixinOff()
		{
			this.InitializeComponent();
		}
		private void InviteBtn_Click(object sender, RoutedEventArgs e)
		{
			List<uint> list = new List<uint>();
			if (this.mCuFriend != null)
			{
				list.Add(this.mCuFriend.nQQ);
				ServiceCenter.sceneSendInviteEmail.doScene(list);
			}
		}
		private void InitWatcher()
		{
			if (this.m_WatcherInviteErr == null)
			{
				this.m_WatcherInviteErr = new EventWatcher(this, null, new EventHandlerDelegate(this.onEventHandlerInviteErr));
				EventCenter.registerEventWatcher(EventConst.ON_NETSCENE_SENDINVITEMAIL_ERR, this.m_WatcherInviteErr);
			}
			if (this.m_WatcherInviteSuc == null)
			{
				this.m_WatcherInviteSuc = new EventWatcher(this, null, new EventHandlerDelegate(this.onEventHandlerInviteSuc));
				EventCenter.registerEventWatcher(EventConst.ON_NETSCENE_SENDINVITEMAIL_SUCCESS, this.m_WatcherInviteSuc);
			}
		}
		private void UnitWatcher()
		{
			if (this.m_WatcherInviteErr != null)
			{
				EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_SENDINVITEMAIL_ERR, this.m_WatcherInviteErr);
				this.m_WatcherInviteErr = null;
			}
			if (this.m_WatcherInviteSuc != null)
			{
				EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_SENDINVITEMAIL_SUCCESS, this.m_WatcherInviteSuc);
				this.m_WatcherInviteSuc = null;
			}
		}
		protected override void OnPageIn(object[] object_0)
		{
			if (object_0 != null && object_0.Length > 0)
			{
				this.mCuFriend = (object_0[0] as QFriend);
				if (this.mCuFriend == null)
				{
					MMMessageBox.Show("error mCuFriend==null", true, "确定");
					return;
				}
				this.QQImg.set_Source(HeadImgMgr.tryGetNowQQHeadImage(this.mCuFriend));
				string text;
				if (!string.IsNullOrEmpty(this.mCuFriend.strQQRemarkName))
				{
					text = this.mCuFriend.strQQRemarkName;
				}
				else
				{
					if (!string.IsNullOrEmpty(this.mCuFriend.strQQNickName))
					{
						text = this.mCuFriend.strQQNickName;
					}
					else
					{
						text = this.mCuFriend.nQQ.ToString();
					}
				}
				this.QQNickNameTxt.Text = text;
				this.QQNumTxt.set_Text(this.mCuFriend.nQQ.ToString());
				this.QQInfoTxt.set_Text(this.mCuFriend.strQQNickName + strings.QQFriend_NoWeinxin);
				this.InitWatcher();
			}
		}
		protected override void OnPageOut()
		{
			this.UnitWatcher();
		}
		private void onEventHandlerInviteErr(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			MessageBoxManager.ShowToast(strings.QQFriend_Invite_fail, 2500, null, false);
		}
		private void onEventHandlerInviteSuc(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			this.OkBtn.set_Visibility(1);
			MessageBoxManager.ShowToast(strings.QQFriend_Invite_OK, 2500, null, false);
		}
		private void SendQQMsgBtn_Click(object sender, RoutedEventArgs e)
		{
			if (!AccountMgr.RecvOfflineQQMsg)
			{
				MMMessageBox.Show(strings.Plugin_QQOffline_OffTip, true, "确定");
				return;
			}
			string username = this.mCuFriend.nQQ.ToString() + "@qqim";
			string qqNickName;
			if (!string.IsNullOrEmpty(this.mCuFriend.strQQRemarkName))
			{
				qqNickName = this.mCuFriend.strQQRemarkName;
			}
			else
			{
				qqNickName = this.mCuFriend.strQQNickName;
			}
			ChatContainerPage.GoToChatPage(this, username, null, qqNickName, null);
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/Plugin/ViewQQInfo/UI/QQFriendInfoWeixinOff.xaml", 2));
			this.LayoutRoot = (Grid)base.FindName("LayoutRoot");
			this.panelTitle = (panelTitle2Line)base.FindName("panelTitle");
			this.ContentPanel = (StackPanel)base.FindName("ContentPanel");
			this.QQArea = (Grid)base.FindName("QQArea");
			this.QQImg = (Image)base.FindName("QQImg");
			this.QQNumTxt = (TextBlock)base.FindName("QQNumTxt");
			this.QQNickNameTxt = (EmojiText)base.FindName("QQNickNameTxt");
			this.QQInfoTxt = (TextBlock)base.FindName("QQInfoTxt");
			this.OkBtn = (Button)base.FindName("OkBtn");
			this.SendQQMsg = (Button)base.FindName("SendQQMsg");
		}
	}
}
